package graph.autodrawer;

import ernie.database.Database;
import graph.Diagram;

import java.util.List;

public class DrawThread extends Thread {

    private final List<Diagram> diagrams;
    private final String dir;
    private final long pause;
    private final Database db;

    public DrawThread(List<Diagram> diagrams, String dir, long pause,
            Database db) {
        this.diagrams = diagrams;
        this.dir = dir;
        this.pause = pause;
        this.db = db;
    }

    @Override
    public void run() {
        while (true) {
            try {
                for (Diagram d : diagrams) {
                    d.drawAndSaveDiagram(db, dir);
                    Thread.sleep(pause);
                }
            } catch (InterruptedException e) {
            }
        }
    }

}
